import { IPSModelSortable } from '../ipsmodel-sortable';
import { IPSSysSFPlugin } from './ipssys-sfplugin';
import { IPSSystemModule } from '../system/ipssystem-module';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysSFPluginImpl extends PSModelObjectImpl implements IPSSysSFPlugin, IPSModelSortable {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  protected pssystemmodule: IPSSystemModule | null = null;

  getPSSystemModule(): IPSSystemModule | null {
    if (this.pssystemmodule != null) return this.pssystemmodule;
    const value = this.M.getPSSystemModule;
    if (value == null) {
      return null;
    }
    this.pssystemmodule = this.getPSModel4('system.IPSSystemModule', value, 'getPSSystemModule') as IPSSystemModule;
    return this.pssystemmodule;
  }

  get psSystemModule(): IPSSystemModule | null {
    return this.getPSSystemModule();
  }

  getPSSystemModuleMust(): IPSSystemModule {
    const value = this.getPSSystemModule();
    if (value == null) {
      throw new Error('未指定系统模块');
    }
    return value;
  }

  get pluginCode(): string {
    return this.M.pluginCode;
  }

  get pluginModel(): IModel {
    return this.M.pluginModel;
  }

  get pluginParams(): IModel {
    return this.M.pluginParams;
  }

  get pluginType(): 'DEACTION' | 'DELOGIC' | 'DELOGICNODE' | 'DEDATASET' | 'USER' | 'SYSREF' | 'MODULE' | 'STRFUNC' | 'MATHFUNC' | 'DOCFUNC' {
    return this.M.pluginType;
  }

  get rTObjectName(): string {
    return this.M.rTObjectName;
  }

  get rTObjectRepo(): string {
    return this.M.rTObjectRepo;
  }

  get rTObjectSource(): number {
    return this.M.rTObjectSource != null ? this.M.rTObjectSource : 0;
  }

  get templCode(): string {
    return this.M.templCode;
  }

  get templCode2(): string {
    return this.M.templCode2;
  }

  get templCode3(): string {
    return this.M.templCode3;
  }

  get templCode4(): string {
    return this.M.templCode4;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get lazyMode(): boolean {
    return this.M.lazyMode != null ? this.M.lazyMode : false;
  }

  get replaceDefault(): boolean {
    return this.M.replaceDefault != null ? this.M.replaceDefault : false;
  }

  get runtimeObject(): boolean {
    return this.M.runtimeObject != null ? this.M.runtimeObject : false;
  }

  get tryMode(): boolean {
    return this.M.tryMode != null ? this.M.tryMode : false;
  }

  get cls(): string {
    return 'PSSysSFPluginImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelSortable' || cls == 'res.IPSSysSFPlugin') return true;
    return super.instanceof(cls);
  }
}
